<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>搜索</title>
<link rel="stylesheet" type="text/css" href="../../css/aui.2.0.css" />
<link href="../../css/main.css" rel="stylesheet" type="text/css">
</head>
<body>
<header class="aui-bar aui-bar-nav top" id="header">
    <a class="aui-pull-left aui-btn cd_icon_fanhui" onclick="api.closeWin();">
        <span class="aui-iconfont aui-icon-left"></span>
    </a>
   	<div class="aui-searchbar search" id="search">
    	<div class="search-input aui-border-radius" tapmode>
        	<i class="aui-iconfont aui-icon-search"></i>
           	<input type="search" placeholder="输入要搜索的内容！" id="search-input" style="font-size: 0.7rem;">
           	<input type="submit" value="搜索" class="sousuo-btn" onclick="gosearch();" />
    	</div>
	</div>
</header>
<script type="text/javascript" src="../../script/api.js"></script>
<script>
var keywordstr,header,header_h,body,body_h,rect_h;
apiready = function() {
	header = $api.byId('header');
	header_h = $api.offset(header).h;
	body = $api.dom('body');
	body_h = $api.offset(body).h;
	rect_h = body_h - header_h;

	if(keywordstr){
		showsearch(showsearch);//展示搜索结果
	}else{
		showtuijian();//展示推荐
	}
}
//点击搜索
function gosearch(){
	keywordstr = $api.val($api.byId('search-input'));
	showsearch();
}
//展示推荐
function showtuijian(){
	api.openFrame({
		name: 'frm_search',
		url: '../frame/search.html',
		scrollEnabled: false,
		bounces:false,
		rect: {x: 0, y: header_h, w: 'auto', h:'auto'},
		showProgress: false,
		reload: false,
		scrollEnabled:true,
	});
}
//展示搜索结果
function showsearch(){
	$api.val($api.byId("search-input"),keywordstr); //显示搜索内容
	api.openFrame({
		name: 'frm_sousuo',
		url: '../frame/sousuo.html',
		scrollEnabled: false,
		bounces:false,
		rect: {x: 0, y: header_h, w: 'auto', h:'auto'},
		showProgress: false,
		reload: true,
		scrollEnabled:true,
		pageParam: {keywords: keywordstr}
	});	
}
</script>
</html>